package com.chatgpt_backend.service.impl;

import com.chatgpt_backend.entity.user.RegisterUser;
import com.chatgpt_backend.mapper.UserMapper;
import com.chatgpt_backend.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    UserMapper userMapper;
    @Override
    public int createAccount(RegisterUser user) {
        if (userMapper.insertUser(user) > 0) {
            if (userMapper.insertRole(userMapper.getAccountIdByUsername(user.getUsername())) > 0)
                return 1;
            else return 0;
        }else return 0;
    }
}
